package com.atguigu.crowd.funding.exception;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author hftang
 * @date 2019-11-02 16:43
 * @desc
 */
public class CrowdFundingAccessDeniedHandler implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response,
                       AccessDeniedException accessDeniedException) throws IOException, ServletException {
        request.setAttribute("exception", accessDeniedException);
        request.getRequestDispatcher("/WEB-INF/system-error.jsp").forward(request, response);
    }

}
